/**   
* @Title: AnimationImageView.java 
* @author zengshuai shi   
* @date 2015年8月24日 下午5:04:39
*/
package com.onstar.cn.weight;

import com.onstar.cn.common.util.BitmapUtil;
import com.onstar.cn.common.util.CommonUtil;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;

/**
 * 
* @ClassName: AnimationImageView 
* @Description: TODO
* @author zengshuai shi
* @date 2015年8月24日 下午5:04:39
 */
public class AnimationImageView extends ImageView {
	public AnimationImageView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		initView();
	}

	public AnimationImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
		initView();
	}

	public AnimationImageView(Context context) {
		super(context);
		initView();
	}

	private void initView() {
		BitmapUtil.recycleImageView(this);
		try {
			//this.setBackgroundResource(R.anim.weight_loading_anim);
		} catch (java.lang.OutOfMemoryError e) {
			e.printStackTrace();
			//this.setBackgroundResource(R.anim.weight_loading_anim);
		}
	}

	@Override
	public void setVisibility(int visibility) {
		super.setVisibility(visibility);
		if (visibility == View.GONE || visibility == View.INVISIBLE) {
			CommonUtil.dismissLoadingAnim(this);
		} else if (visibility == View.VISIBLE) {
			CommonUtil.showLoadingAnim(this);
		}
	}
}
